package com.rchat.pocmini.activity.forgetpwd;

import com.aso.common.http.delegate.HttpCallbackImpl;
import com.aso.common.http.utils.HttpUtils;
import com.rchat.pocmini.global.AppGlobal;
import com.rchat.pocmini.global.HttpCodeGlobal;
import com.rchat.pocmini.global.RequestParam;
import com.rchat.pocmini.global.UrlsGlobal;

import java.util.HashMap;
import java.util.Map;

/**
 * Created by ljd on 2017/7/28.
 */

public class ForgetPwdModelImpl implements ForgetPwdContract.Model {

    @Override
    public void getVerificationCode(String phone, HttpCallbackImpl callback) {
        Map<String, String> param = new HashMap<>();
        param.put("mobile", phone);
        param.put("appType", AppGlobal.APPTYPE);
        //body = {"code":2002,"data":{"platform":1,"version":"1.0","enterprise":1,"mobile":"xxxxxxxxxxx","appType":"0"}}
        String body = RequestParam.requestRootParam(HttpCodeGlobal.REQ_CODE_2002, param);
        HttpUtils.postAsyn(UrlsGlobal.getUrl(UrlsGlobal.GET_VERIFICATION_CODE_URL), body, callback);
    }

    @Override
    public void resetPwd(String verificationCode, String phone, String pwd, HttpCallbackImpl callback) {
        Map<String, String> param = new HashMap<>();
        param.put("identifyCode", verificationCode);
        param.put("phone", phone);
        param.put("password", pwd);
        //body = {"code":1014,"data":{"platform":1,"version":"1.0","enterprise":1,"phone":"xxxxxxxxxx","password":"123456","identifyCode":"490232"}}
        String body = RequestParam.requestRootParam(HttpCodeGlobal.REQ_CODE_1014, param);
        HttpUtils.postAsyn(UrlsGlobal.getUrl(UrlsGlobal.RESET_PWD_URL), body, callback);
    }
}
